package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class RestFulController {
    //http://localhost:8080/add?a=1&b=2原来的
    //restful风格 http://localhost:8080/add/1/123
    //@RequestMapping(value = "/add/{a}/{b}", method = RequestMethod.GET) //第一种方式
    @GetMapping("/add/{a}/{b}") //第二种方式
    public String test1(@PathVariable int a, @PathVariable int b, Model model) {

        model.addAttribute("msg", "结果为：" + (a + b));

        return "test";
    }
}
